Sequence Examples

Swapping of two numbers with additional variable

Step 1: Start
Step 2: Read the first number a
Step 3: Read the second number b
Step 4: Consider a temporary variable, t and Assign t with a's value
t=a
Step 5: Assign a with b's value
a=b
Step 6: Assign b with t's value
b=t
Step 7: Print a, b after swapping
Step 8: Stop

Find area and circumference of a circle

Step 1: Start
Step 2: Input the radius of the circle
Step 3: Find area and circumference of circle
area=3.14*r*r
circumference = 2*3.14*r
Step 4: Print the value of area and circumference of the circle
Step 5: Stop

Calculate the Simple Interest for the given Principal, rate of Interest and period of time.

Step 1: Start
Step 2: Input Principal Amount, Rate of interest and period of Time
Step 3: Find the simple Interest using formula
SI= ((amount*rate*time)/100)
Step 4: Print Simple Interest
Step 5: Stop

Convert Celsius to Fahrenheit

Step 2: Input Celsius
Step 3: Find Fahrenheit using the formula
F=9/5(C) +32
Step 4: Print Fahrenheit
Step 5: Stop

Convert Bytes into Kilo Bytes, Mega Bytes, Giga Bytes and Tera Bytes.

Step 2: Read Bytes
Step 3: Find KiloBytes=Bytes/1024
Step 4: Find MegaBytes=kiloBytes/1024
Step 5: Find GigaBytes=MegaBytes/1024
Step 6: Find TeraBytes=GigaBytes/1024
Step 7: Print KiloBytes, MegaBytes, GigaBytes, TeraBytes.
Step 8: Stop

References

  • Allen B. Downey, “Think Python: How to Think Like a Computer Scientist‘‘, 2nd edition, Updated for Python 3, Shroff/O‘Reilly Publishers, 2016 (http://greenteapress.com/wp/thinkpython/)
  • Guido van Rossum and Fred L. Drake Jr, ―An Introduction to Python – Revised and updated for Python 3.2, Network Theory Ltd., 2011.
  • John V Guttag, ―Introduction to Computation and Programming Using Python‘‘, Revised and expanded Edition, MIT Press , 2013
  • Robert Sedgewick, Kevin Wayne, Robert Dondero, ―Introduction to Programming in Python: An Inter-disciplinary Approach, Pearson India Education Services Pvt. Ltd., 2016.
  • Timothy A. Budd, ―Exploring Python‖, Mc-Graw Hill Education (India) Private Ltd.,, 2015. 4. Kenneth A. Lambert, ―Fundamentals of Python: First Programs‖, CENGAGE Learning, 2012.
  • Charles Dierbach, ―Introduction to Computer Science using Python: A Computational Problem-Solving Focus, Wiley India Edition, 2013.
  • Paul Gries, Jennifer Campbell and Jason Montojo, ―Practical Programming: An Introduction to Computer Science using Python 3‖, Second edition, Pragmatic Programmers, LLC, 2013.